package com.sc.nft.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.EquityProps;
import com.sc.nft.entity.UserEquityProps;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.congestive.GiftCT;
import com.sc.nft.entity.dto.*;
import com.sc.nft.entity.vo.*;
import com.sc.nft.entity.vo.secondEquityProp.EquityPropsLastConsignDetailsVO;
import com.sc.nft.entity.vo.secondEquityProp.RealAmountVO;
import com.sc.nft.enums.EquityPropsTypeEnum;
import com.sc.nft.enums.UserEquityPropsGetTypeEnum;
import com.sc.nft.enums.UserEquityPropsHoldingStatusEnum;
import com.sc.nft.enums.UserEquityPropsUseTypeEnum;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 用户权益道具表服务接口
 *
 * @author Sun
 * @description 由 Mybatisplus Code Generator 创建
 * @since 2023-03-28 10:28:43
 */
public interface UserEquityPropsService {


    /**
     * 获取道具下用户持有数量
     *
     * @param mallEquityUserHold mallEquityUserHold
     * @return MallEquityUserHoldVo
     */
    IPage<MallEquityUserHoldVo> pageEquityHold(MallEquityUserHoldDTO mallEquityUserHold);

    /**
     * 用户持有数量
     *
     * @param equityPropsId 权益道具id
     * @param userId        用户id
     * @return
     */
    Integer getHavingCountByUserId(Long equityPropsId, Long userId);


    Integer getHavingCountByUserId(Long equityPropsId, EquityPropsTypeEnum equityPropsType, Long userId);


    /**
     * 根据用户id和权益道具id查询用户持有的权益道具
     *
     * @param userId
     * @param equityPropsId
     * @param size
     * @return
     */
    List<UserEquityProps> getHavingListByUserIdAndEquityPropsIdAndLimit(Long userId, Long equityPropsId, Integer size);

    /**
     * 修改用户权益道具为冻结
     *
     * @param list
     */
    Boolean updateBatchById(List<UserEquityProps> list);


    /**
     * 修改用户权益道具状态
     *
     * @param ids
     */
    Boolean updateHoldStatusBatchById(List<Long> ids, UserEquityPropsHoldingStatusEnum statusEnum, UserEquityPropsHoldingStatusEnum beforeStatusEnum);

    /**
     * 冻结转消耗
     *
     * @param userEquityPropsIds
     * @return
     */
    Boolean freezePropsToUseByIds(String userEquityPropsIds, Long userId, Integer count, String relationTitle, Long relationId);

    /**
     * 冻结转正常持有
     *
     * @param userEquityPropsIds
     * @return
     */
    Boolean freezePropsToNormalByIds(String userEquityPropsIds, Long userId);


    /**
     * 扣减抽奖券
     *
     * @param equityPropsType
     * @param userId
     * @return
     */
    void subVoucher(Long equityPropsId, EquityPropsTypeEnum equityPropsType, Long userId, int num, String relationTitle, Long relationId);

    /**
     * 消耗道具
     *
     * @param equityPropsType
     * @param userId
     * @return
     */
    List<Long> subVoucher(Long equityPropsId, EquityPropsTypeEnum equityPropsType, Long userId, int num, String relationTitle, Long relationId, UserEquityPropsUseTypeEnum userEquityPropsUseTypeEnum);

    /**
     * 批量使用不同的兑换卷抽奖券等进行扣除
     *
     * @param equityPropsId
     * @param userId
     * @param num
     * @param relationTitle
     * @param relationId
     * @param equityPropsType
     */
    void subVoucher(Long equityPropsId, Long userId, int num, String relationTitle, Long relationId, EquityPropsTypeEnum... equityPropsType);

    /**
     * 扣减抽奖券,该方法只允许一次扣一个.会返回扣除的抽奖券id主键.多个请不要调用.
     *
     * @param equityPropsId
     * @param equityPropsType
     * @param userId
     * @param relationTitle
     * @param relationId
     * @return
     */
    Long subVoucherIndependent(Long equityPropsId, EquityPropsTypeEnum equityPropsType, Long userId, String relationTitle, Long relationId);

    /**
     * 兑换权益卡专用
     *
     * @param equityProps
     * @param userId
     * @param getType
     * @param count
     * @param relationTitle
     * @param relationId
     * @param buyPrice
     * @param activityId    活动id
     * @return
     */
    UserEquityProps exchangeEquityPropsByUser(EquityProps equityProps, Long userId, UserEquityPropsGetTypeEnum getType, Integer count, String relationTitle, Long relationId, BigDecimal buyPrice, Long activityId, UserEquityPropsGetTypeEnum primeType, Long primeId);


    /**
     * 添加用户权益道具
     *
     * @param equityProps
     */
    UserEquityProps addEquityPropsByUser(EquityProps equityProps, Long userId, UserEquityPropsGetTypeEnum getType, Integer count, String relationTitle, Long relationId, BigDecimal buyPrice, UserEquityPropsGetTypeEnum primeType, Long primeId);

    /**
     * 添加用户权益道具(二级购买)
     *
     * @param equityProps
     */
    UserEquityProps buyEquityPropsByUser(EquityProps equityProps, Long userId, UserEquityPropsGetTypeEnum getType, List<UserEquityProps> userEquityPropsList, String relationTitle, Long relationId, BigDecimal buyPrice);

    /**
     * 获取用户权益道具记录
     *
     * @param isConsume
     * @param pageNo
     * @param pageSize
     * @return
     */
    Page<PageEquityPropsLogVO> getPageEquityPropsLog(UserInfo userInfo, Integer isConsume, Integer pageNo, Integer pageSize);

    /**
     * 获取用户权益道具
     *
     * @param user
     * @param isExpired
     * @param pageNo
     * @param pageSize
     * @return
     */
    Page<PageUserEquityPropsVO> getPageUserEquityProps(UserInfo user, Integer isExpired, Integer pageNo, Integer pageSize);

    /**
     * 正常转消耗
     *
     * @param list
     * @return
     */
    Boolean normalToconsumeByIds(List<UserEquityProps> list, Long userId, String relationTitle, Long relationId, UserEquityPropsUseTypeEnum useType);

    /**
     * 转增损耗计算
     *
     * @param incrementalLossCalculationDTO
     * @return
     */
    List<IncrementalLossCalculationVO> incrementalLossCalculation(IncrementalLossCalculationDTO incrementalLossCalculationDTO, UserInfo user);

    /**
     * 赠送
     *
     * @param giftCT
     */
    void gift(GiftCT giftCT);

    /**
     * 通过链地址获取用户信息
     *
     * @param addressUserInfoDTO
     * @return
     */
    AddressUserInfoVO addressUserInfo(AddressUserInfoDTO addressUserInfoDTO, UserInfo userInfo);

    /**
     * 后台-用户权益道具列表
     *
     * @param userTel
     * @param firstTitle
     * @param getBeginTime
     * @param getEndTime
     * @param expiredBeginTime
     * @param expiredEndTime
     * @param page
     * @return
     */
    Page<AdminUserEquityPropsPagVO> getAdminUserEquityPropsPage(String userTel, String firstTitle, Date getBeginTime, Date getEndTime, Date expiredBeginTime, Date expiredEndTime, Page page, Integer onConsignStatus);

    /**
     * 批量修改过期时间
     *
     * @param ids
     * @param expiredTime
     */
    void batchEditExpiredTime(List<Long> ids, Date expiredTime);

    /**
     * 我的权益道具
     *
     * @param userId
     * @param pageNo
     * @param pageSize
     * @return
     */

    Page<UserEquityPropsVO> getMyEquity(Long userId, Integer pageNo, Integer pageSize);

    /**
     * 我的权益道具明细
     *
     * @param userId
     * @param id
     * @param isExpired
     * @param page
     * @param isGift
     * @return
     */
    Page<UserEquityPropsDetailVO> getMyEquityDetail(Long userId, Long id, Integer isExpired, Page page, Boolean isGift);

    /**
     * 获取最新寄售信息
     *
     * @param equityPropsId
     * @return
     */
    EquityPropsLastConsignDetailsVO getLastConsignDetails(Long equityPropsId);

    /**
     * 用户可寄售权益道具列表
     *
     * @param equityPropsId
     * @param page
     * @return
     */
    Page<UserConsignEquityPropsPageVO> getUserConsignEquityPropsPage(Long equityPropsId, UserInfo user, Page page);

    /**
     * 寄售 计价
     *
     * @param user
     * @param equityPropsId
     * @param userEquityPropsIds
     * @param consignPrice
     * @return
     */
    RealAmountVO getUserRealPrice(UserInfo user, Long equityPropsId, List<Long> userEquityPropsIds, BigDecimal consignPrice);

    /**
     * 寄售权益道具
     *
     * @param equityPropsId
     * @param userEquityPropsIds
     * @param consignPrice
     */
    void consignEquityProps(UserInfo user, Long equityPropsId, List<Long> userEquityPropsIds, BigDecimal consignPrice);

    /**
     * 判断用户是否持有某种道具卡
     *
     * @param userId
     * @param equityPropsId
     * @return
     */
    Boolean getIsHoldEquityDetail(Long userId, Long equityPropsId);

    /**
     * 获取用户拥有的道具
     *
     * @param userId
     * @param propName
     * @return
     */
    List<HoldPropDataVO> holdProp(Long userId, String propName);

    /**
     * 获取用户拥有的道具
     */
    List<HoldPropDataVO> getSingleHoldEquityPropDataByUserIdAndEquityPropId(Long userId, Long id);


    /**
     * 获取用户拥有的道具分页集合
     *
     * @param userId
     * @param pageNo
     * @param pageSize
     * @param id
     * @return
     */
    Page<HoldPropDataVO> getSingleHoldEquityPropData(Long userId, Integer pageNo, Integer pageSize, Long id);


    /**
     * @param userEquityPropsId
     * @param orderId
     * @param salesUserId
     * @param buyUserId
     * @param payTime
     * @return
     */
    void updateToSales(Long equityPropsId, Long userEquityPropsId, Long orderId, Long salesUserId, Long buyUserId, Date payTime);

    void updateWantSellToSales(Long equityPropsId, Long userEquityPropsId, Long orderId, Long salesUserId, Long buyUserId, Date payTime);

    void updateWantBuyOrderToSales(Long equityPropsId, Long userEquityPropsId, Long orderId, Long salesUserId, Long buyUserId, Date payTime);

    /**
     * 获取用户的权益道具
     *
     * @param userEquityPropsIds
     */
    List<UserEquityProps> getListByIds(List<Long> userEquityPropsIds);

    /**
     * 获取用户权益道具和删除的
     *
     * @param userEquityPropsIds
     * @return
     */
    List<UserEquityProps> getListByIdsAndDelete(List<Long> userEquityPropsIds);

    /**
     * 拍卖道具处理
     *
     * @param userEquityPropsIdList
     * @param giveMap
     * @param relationId
     * @return
     */
    void disposalOfAuctionItems(List<Long> userEquityPropsIdList, Map<Long, Integer> giveMap, Long relationId, Long copyrightAuctionId, Long copyrightAuctionRecordId);


    /**
     * 拍卖道具处理
     *
     * @param giveMap
     * @return
     */
    void disposalOfAuctionItems(Map<Long, Integer> giveMap, EquityProps equityProps);

    /**
     * <<<<<<< HEAD
     * 商城发放道具
     *
     * @param mallIssuePropEquityDTO
     */
    void mallIssuePropEquity(MallIssuePropEquityDTO mallIssuePropEquityDTO);

    /**
     * 商城使用道具
     *
     * @param mallDeductPropEquityDTO
     */
    void mallSubtractPropEquity(MallDeductPropEquityDTO mallDeductPropEquityDTO);

    /**
     * 分页获取用户道具
     *
     * @param vistInFlagUserDTO
     * @return
     */
    IPage<MallUserEquityPropsVO> pageUserEquityProps(VistInFlagUserDTO vistInFlagUserDTO);

    /**
     * 获取用户道具持有数量
     *
     * @param userId
     * @param equityPropsIds
     * @return
     */
    List<UserHoldPropsCountVO> getUserPropsHoldCount(Long userId, List<Long> equityPropsIds);
}
